﻿Imports System.IO
Imports System.Net
Imports System.Text

Module Module1
    Public Cookies As New CookieContainer
    Public DB As Sy.Data.SQLite
    Public DB8 As Sy.Data.SQLite
    Public DB2 As Sy.Data.SQLite
    Public DB4 As Sy.Data.SQLite
    Public UserNamelo As String
    Public Userpasslo As String
    Public picurl As String
    Public picurl2 As String
    Public jumpurl As String
    Public is_vip As String
    Public amount As Decimal
    Public task_name As String
    Public tradecookie As String
    Public amazoncookie As String
    Public brandlistname As String
    Public Thecountry As String
    Public stcountry As String
    Public stkeywd As String
    'Public Version = "米境通跨境电商图片批量处理工具"
    Public Version = "米境通僵尸无主Asin采集工具"
    'Public Version = "米境通亚马逊选品工具"
    'Public Version = "米境通百度统计分析工具"
    'Public Version = "米境通亚马逊关键词分析工具"
    'Public Version = "UPC-EAN条码生成校验工具"
    Public logintime As String
    Public searchkeyword As String
    Public starturl As String
    Public tabsindex As TabPage
    Public WithEvents CefWeb As New Sy.UI.CefBrowser
    Public WithEvents CefWeb2 As New Sy.UI.CefBrowser
    Public WithEvents CefWeb3 As New Sy.UI.CefBrowser
    Sub loadkwy()
        Form1.keyword.Items.Clear()
        Dim sql As String = "select * from t_TaskList7 where gj='" & Form1.country.Text & "';"
        Dim reader As Data.Common.DbDataReader = DB2(sql)
        Do While reader.Read
            Form1.keyword.Items.Add(reader("keyword"))
        Loop
        If Form1.keyword.Items.Count > 0 Then
            Form1.keyword.SelectedIndex = 0
        End If
    End Sub

    Function trimsql(str As String)
        Return Trim(Replace(str, "'", "''"))
    End Function
    Function getdomain(str) As String
        Try
            Dim url = Split(str, "/")
            Dim newurl = url(0) & "//" & url(2)
            Return newurl
        Catch ex As Exception
            Return "/"
        End Try
    End Function

    Function waitfor(Cef As Sy.UI.CefBrowser, url As String, Signal As String, Optional waiterr As String = "", Optional frms As Form = Nothing, Optional errinfo1 As String = "", Optional errinfo2 As String = "") As String
        Try
            Dim i = 0
            Dim r = 0
            Do
                Dim html As String = ""
                Dim nhtml As String = ""
                Try
                    'Console.WriteLine($"getbrhtml:{Cef.Url}")
                    If Cef.CanExecuteJavascriptInMainFrame Then
                        html = Cef.GetDomHtml()
                    End If
                    '    CefWeb.GetBrowser.MainFrame.GetSourceAsync().ContinueWith(Sub()
                    '                                                                  Dim shtml = CefWeb.GetBrowser.MainFrame.GetSourceAsync().Result
                    '                                                                  If InStr(shtml.ToLower, "</html>") > 0 Then
                    '                                                                      html = shtml
                    '                                                                      Console.WriteLine(html)
                    '                                                                  End If
                    '                                                              End Sub
                    ')
                    'html = Cef.GetBrowser.MainFrame.GetSourceAsync().Result
                Catch ex As Exception
                    html = ""
                End Try
                nhtml = html.ToLower()
                'nhtml = "validatecaptcha"
                'If nhtml = "<html><head></head><body></body></html>" Then
                '    i += 1
                '    r += 1
                'End If
                'If i >= 10 Then
                '    'CefWebtt.Load(url)
                '    Threading.Thread.Sleep(1000)
                '    i = 0
                'End If
                'If r >= 20 Then
                '    Return ""
                'End If
                Dim Arr = {Signal, errinfo1, errinfo2, "<!-- for body -->"}
                Dim Checks = Arr.Where(Function(o) o.IsNotEmpty()).ToArray()
                Dim Systr As Sy.String = nhtml
                If Systr.ContainsOne(Checks) Then Return html

                'If InStr(nhtml, Signal) > 0 Then
                '    Return html
                'End If
                'If errinfo1 <> "" Then
                '    If InStr(nhtml, errinfo1) > 0 Then
                '        Return html
                '    End If
                'End If
                'If errinfo2 <> "" Then
                '    If InStr(nhtml, errinfo2) > 0 Then
                '        Return html
                '    End If
                'End If
                If waiterr <> "" Then
                    If InStr(nhtml, waiterr) > 0 Then
                        Console.WriteLine("唤起输入验证码窗体")

                        'nhtml = CType(frms.InvokEx(Function() Frm_Capture.Instance.ShowDialog(frms, url)), String)
                        nhtml = CType(frms.InvokEx(Function() Frm_Capture.Instance.ShowDialog(frms, url)), String)

                        If InStr(nhtml.ToLower(), waiterr) <= 0 Then
                            Return nhtml
                        End If
                        Console.WriteLine("验证码窗体被关闭")
                            'CefWeb2.Load(url)
                            'Return waitfor(Cef, url, Signal, waiterr, errinfo1, errinfo2)
                            'Do Until Form5.Visible = False
                            '    Application.DoEvents()
                            '    Threading.Thread.Sleep(2000)
                            'Loop
                        End If
                    End If
                Application.DoEvents()
                Threading.Thread.Sleep(2000)
                r += 1
                If r >= 20 Then
                    Return ""
                End If
            Loop
        Catch ex As Exception
            Return ""
        End Try
    End Function

    Function getnewhtml(url As String, Optional Method As String = "GET", Optional formdata As String = "", Optional cookie As String = "", Optional UserAgent As String = "", Optional Referer As String = "", Optional Accept As String = "", Optional ContentType As String = "", Optional AllowAutoRedirect As Boolean = True, Optional KeepAlive As Boolean = True)

        Dim request = CType(WebRequest.Create(url), HttpWebRequest)
        Try
            If Referer = "" Then
                Referer = request.Host
            End If
            If UserAgent = "" Then
                UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
            End If
            If Accept = "" Then
                Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"
            End If
            If ContentType = "" Then
                ContentType = "text/html; charset=utf-8"
            End If
            request.Referer = Referer
            request.Proxy = Nothing
            request.UserAgent = UserAgent

            If cookie IsNot Nothing Then
                Dim webcookie As String = cookie
                Dim wk() As String = Split(webcookie, ";")
                For Each scookie In wk
                    If scookie <> "" Then
                        Dim cookieNameValue() As String
                        Dim ck As Net.Cookie
                        If InStr(scookie, "=") > 1 Then
                            Dim dcookie = Split(scookie, "=")(0)
                            Dim ecookie = Split(scookie, dcookie & "=")(1).Replace(",", "%2c")

                            Console.WriteLine(scookie)
                            ck = New Net.Cookie(Replace(Trim(dcookie.ToString), vbCrLf, ""), Replace(Trim(ecookie.ToString), vbCrLf, ""), "/", request.Host)
                        Else
                            'cookieNameValue = Split(scookie, "=")
                            'ck = New Net.Cookie(Replace(Trim(cookieNameValue(0).ToString), vbCrLf, ""), Replace(Trim(cookieNameValue(1).ToString), vbCrLf, ""), "/", request.Host)
                        End If

                        'Console.WriteLine(Trim(cookieNameValue(0).ToString) & ":" & Trim(cookieNameValue(1).ToString))
                        Cookies.Add(ck)
                    End If
                Next
            End If
            request.CookieContainer = Cookies
            request.Method = Method
            request.Headers.Add("sec-ch-ua", """ Not;A Brand"";v=""99"", ""Google Chrome"";v=""91"", ""Chromium"";v=""91""")
            request.Headers.Add("sec-ch-ua-mobile", "?0")
            request.Headers.Add("sec-fetch-dest", "document")
            request.Headers.Add("sec-fetch-mode", "navigate")
            request.Headers.Add("sec-fetch-site", "same-origin")
            request.Headers.Add("sec-fetch-user", "?1")
            request.Headers.Add("upgrade-insecure-requests", "1")
            'request.Headers.Add("accept-encoding", "gzip, deflate, br")
            request.Headers.Add("cache-control", "no-cache")
            'request.Headers.Add("Authorization", "APPCODE 2d72d998c0c642e9835d9fad8cb8039e")
            'request.Headers.Add("anti-csrftoken-a2z", "gCZ2hWqGJHJ8/uQMRxEbXWehVFQraGStZhW6vMEAAAAMAAAAAGG2MFpyYXcAAAAA")
            request.Accept = Accept
            request.ContentType = ContentType
            request.AllowAutoRedirect = AllowAutoRedirect
            request.KeepAlive = KeepAlive
            If Method = "POST" Then
                Dim strbyte() As Byte = System.Text.Encoding.ASCII.GetBytes(formdata)
                request.ContentLength = strbyte.Length
                Dim stream As IO.Stream = request.GetRequestStream
                stream.Write(strbyte, 0, strbyte.Length)
                stream.Flush()
            End If

            Dim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)
            Cookies.Add(response.Cookies)
            Dim res As Stream = response.GetResponseStream()
            Dim reader As New StreamReader(res, Encoding.GetEncoding("utf-8"))
            Dim html = reader.ReadToEnd()
            request.Abort()
            request = Nothing
            reader.Close()
            res.Close()
            response.Close()
            response = Nothing
            res = Nothing
            reader = Nothing
            Return html
        Catch ex As Exception
            request.Abort()
            request = Nothing
            Return ""
        End Try
    End Function
    Function getbrand(str) As String
        Try
            Dim mbrand As String = ""
            str = str.ToString.ToLower
            'If InStr(str, "a-link-normal"" href=""/stores/") > 0 Then
            '    Dim branda = Split(str, "a-link-normal"" href=""/stores/")(1)
            '    mbrand = Split(branda, "title_feature_div")(0).ToString
            '    If InStr(mbrand, "/page/") Then
            '        Dim cbrand = Split(mbrand, "/page/")(0).ToString
            '        Return HttpUtility.UrlDecode(cbrand)
            '    End If
            '    If InStr(mbrand, "<img alt=""") Then
            '        Dim cbrand = Split(mbrand, "<img alt=""")(1).ToString
            '        Dim dbrand = Split(cbrand, """ src=")(0).ToString
            '        Return HttpUtility.UrlDecode(dbrand)
            '    End If
            '    Return HttpUtility.UrlDecode(mbrand)
            'End If
            'If InStr(str, "field-keywords=") > 0 Then
            '    Dim branda = Split(str, "field-keywords=")(1)
            '    mbrand = Split(branda, """>")(0).ToString
            '    Return HttpUtility.UrlDecode(mbrand)
            'End If
            'If InStr(str, "field-brandtextbin=") > 0 Then
            '    Dim branda = Split(str, "field-brandtextbin=")(1)
            '    mbrand = Split(branda, """>")(0).ToString
            '    If InStr(mbrand, "&") > 0 Then
            '        mbrand = Split(mbrand, "&")(0).ToString
            '    End If
            '    Return HttpUtility.UrlDecode(mbrand)
            'End If
            'If InStr(str, ";field-lbr_brands_browse-bin=") > 0 Then
            '    Dim branda = Split(str, ";field-lbr_brands_browse-bin=")(1)
            '    mbrand = Split(branda, """>")(0).ToString
            '    Return HttpUtility.UrlDecode(mbrand)
            'End If
            'com,uk,ca,au
            'logo
            If InStr(str, "</a> <div class=""a-section") > 0 Then
                Dim branda = Split(str, "</a> <div class=""a-section")(0)
                Dim brandb = Split(branda, "dp_brandlogo_sto"">")
                mbrand = Trim(brandb(UBound(brandb)))
                If mbrand.Length < 50 And mbrand.Length > 0 Then
                    Return mbrand
                End If
            End If
            If InStr(str, "field-author=") > 0 Then
                Dim branda = Split(str, "field-author=")(1)
                Dim brandb = Split(branda, "&")(0)
                mbrand = Trim(Replace(brandb, "+", " "))
                If mbrand.Length < 50 And mbrand.Length > 0 Then
                    Return mbrand
                End If
            End If
            If InStr(str, "id=""brandteaser") > 0 Then
                Dim branda = Split(str, "id=""brandteaser")(1)
                Dim brandb = Split(branda, "id=""logobyline")(0)
                Dim brandc = Split(brandb, "<img alt=""")(1)
                Dim brandd = Trim(Split(brandc, """ src=")(0))
                If brandd.Length < 50 And brandd.Length > 0 Then
                    Return brandd
                End If
            End If
            If InStr(str, ">brand:") > 0 Then
                Dim branda = Split(str, ">brand:")(1)
                mbrand = Trim(Split(branda, "</a>")(0))
                If mbrand.Length < 50 And mbrand.Length > 0 Then
                    Return mbrand
                End If
            End If
            If InStr(str, ">visit the") > 0 Then
                Dim branda = Split(str, ">visit the")(1)
                mbrand = Trim(Split(branda, "store</a>")(0))
                If mbrand.Length < 50 And mbrand.Length > 0 Then
                    Return mbrand
                End If
            End If
            'mx,es
            If InStr(str, ">visita la store de") > 0 Then
                Dim branda = Split(str, ">visita la store de")(1)
                mbrand = Trim(Split(branda, "</a>")(0))
                If mbrand.Length < 50 And mbrand.Length > 0 Then
                    Return mbrand
                End If
            End If
            If InStr(str, ">visita la tienda de") > 0 Then
                Dim branda = Split(str, ">visita la tienda de")(1)
                mbrand = Trim(Split(branda, "</a>")(0))
                If mbrand.Length < 50 And mbrand.Length > 0 Then
                    Return mbrand
                End If
            End If
            If InStr(str, ">marca:") > 0 Then
                Dim branda = Split(str, ">marca:")(1)
                mbrand = Trim(Split(branda, "</a>")(0))
                If mbrand.Length < 50 And mbrand.Length > 0 Then
                    Return mbrand
                End If
            End If
            'fr
            If InStr(str, ">visiter la boutique") > 0 Then
                Dim branda = Split(str, ">visiter la boutique")(1)
                mbrand = Trim(Split(branda, "</a>")(0))
                If mbrand.Length < 50 And mbrand.Length > 0 Then
                    Return mbrand
                End If
            End If
            If InStr(str, ">marque&nbsp;:") > 0 Then
                Dim branda = Split(str, ">marque&nbsp;:")(1)
                mbrand = Trim(Split(branda, "</a>")(0))
                If mbrand.Length < 50 And mbrand.Length > 0 Then
                    Return mbrand
                End If
            End If
            'de
            If InStr(str, ">marke:") > 0 Then
                Dim branda = Split(str, ">marke:")(1)
                mbrand = Trim(Split(branda, "</a>")(0))
                If mbrand.Length < 50 And mbrand.Length > 0 Then
                    Return mbrand
                End If
            End If
            If InStr(str, ">besuchen sie den") > 0 Then
                Dim branda = Split(str, ">besuchen sie den")(1)
                mbrand = Trim(Split(branda, "-store</a>")(0))
                If mbrand.Length < 50 And mbrand.Length > 0 Then
                    Return mbrand
                End If
            End If
            'it
            If InStr(str, ">marca:") > 0 Then
                Dim branda = Split(str, ">marca:")(1)
                mbrand = Trim(Split(branda, "</a>")(0))
                If mbrand.Length < 50 And mbrand.Length > 0 Then
                    Return mbrand
                End If
            End If
            If InStr(str, ">visita lo store di") > 0 Then
                Dim branda = Split(str, ">visita lo store di")(1)
                mbrand = Trim(Split(branda, "</a>")(0))
                If mbrand.Length < 50 And mbrand.Length > 0 Then
                    Return mbrand
                End If
            End If
            'nl
            If InStr(str, ">merk:") > 0 Then
                Dim branda = Split(str, ">merk:")(1)
                mbrand = Trim(Split(branda, "</a>")(0))
                If mbrand.Length < 50 And mbrand.Length > 0 Then
                    Return mbrand
                End If
            End If
            'pl
            If InStr(str, ">marka:") > 0 Then
                Dim branda = Split(str, ">marka:")(1)
                mbrand = Trim(Split(branda, "</a>")(0))
                If mbrand.Length < 50 And mbrand.Length > 0 Then
                    Return mbrand
                End If
            End If
            'se
            If InStr(str, ">varumärke:") > 0 Then
                Dim branda = Split(str, ">varumärke:")(1)
                mbrand = Trim(Split(branda, "</a>")(0))
                If mbrand.Length < 50 And mbrand.Length > 0 Then
                    Return mbrand
                End If
            End If
            'jp
            If InStr(str, ">ブランド:") > 0 Then
                Dim branda = Split(str, ">ブランド:")(1)
                Dim brandc = Split(branda, "</a>")(0)
                If InStr(brandc, "(") > 0 Then
                    Dim brandb = Split(brandc, "(")(1)
                    mbrand = Trim(Split(brandb, ")")(0))
                Else
                    mbrand = brandc
                End If
                If mbrand.Length < 50 And mbrand.Length > 0 Then
                    Return mbrand
                End If
            End If
            If InStr(str, "ref_=ast_bln"">") > 0 And InStr(str, "のストアを表示") > 0 Then
                Dim branda = Split(str, "ref_=ast_bln"">")(1)
                Dim brandc = Split(branda, "のストアを表示")(0)
                If InStr(brandc, "(") > 0 Then
                    Dim brandb = Split(brandc, "(")(1)
                    mbrand = Trim(Split(brandb, ")")(0))
                Else
                    mbrand = brandc
                End If
                If mbrand.Length < 50 And mbrand.Length > 0 Then
                    Return mbrand
                End If
            End If
            'in
            If InStr(str, "ब्रांड:") > 0 Then
                Dim branda = Split(str, "ब्रांड:")(1)
                Dim brandc = Split(branda, "</a>")(0)
                mbrand = Trim(brandc)
                If mbrand.Length < 50 And mbrand.Length > 0 Then
                    Return mbrand
                End If
            End If
            If InStr(str, "ref_=ast_bln"">") > 0 And InStr(str, "store पर जाएं") > 0 Then
                Dim branda = Split(str, "ref_=ast_bln"">")(1)
                Dim brandc = Split(branda, "store पर जाएं")(0)
                If InStr(brandc, "-") > 0 Then
                    Dim brandb = Split(brandc, "-")(1)
                    mbrand = Trim(brandb)
                Else
                    mbrand = brandc
                End If
                If mbrand.Length < 50 And mbrand.Length > 0 Then
                    Return mbrand
                End If
            End If

            Return mbrand
        Catch ex As Exception
            Return ""
        End Try
    End Function
    Function gettitle(str)
        Try
            Dim titlea = Split(str, "],""title"":""")(1)
            Dim titleb = Split(titlea, """,")(0)
            Return titleb
        Catch ex As Exception
            Return ""
        End Try
    End Function
    Function getstars(str)
        str = str.ToString.ToLower
        Dim stars = "0"
        Try
            If InStr(str, "reviewcounttextlinkedhistogram nounderline"" title=""") Then
                Dim starsa = Split(str, "reviewcounttextlinkedhistogram nounderline"" title=""")(1)
                If InStr(starsa, "5つ星のうち") > 0 Then
                    Dim starst = Split(starsa, "5つ星のうち")(1)
                    Dim starsc = Left(starst, 3)
                    Return starsc
                End If
                If InStr(starsa, "5 में से ") > 0 Then
                    Dim starst = Split(starsa, "5 में से ")(1)
                    Dim starsc = Left(starst, 3)
                    Return starsc
                End If
                Dim starsb = Replace(Left(starsa, 3), ",", ".")
                If starsb = "" Then
                    Return "0"
                Else
                    Return starsb
                End If
            Else
                Return stars
            End If
        Catch ex As Exception
            Return "0"
        End Try
    End Function

    Function getreview(str) As String
        str = str.ToString.ToLower
        Try
            If InStr(str, "id=""acrcustomerreviewtext"" class=""a-size-base"">") > 0 Then
                Dim reviewa = Split(str, "id=""acrcustomerreviewtext"" class=""a-size-base"">")(1)
                Dim reviewb = Split(reviewa, "</span>")(0).ToString
                If reviewb = "" Then
                    Return "0"
                Else
                    Return reviewb
                End If
            Else
                Return "0"
            End If
        Catch ex As Exception
            Return "0"
        End Try
    End Function
    Function getasin(str) As String
        Try
            If InStr(str, "pageTypeId: """) Then
                Dim asina = Split(str, "pageTypeId: """)(1)
                Dim asinb = Split(asina, """}")(0)
                Return asinb
            Else
                Return ""
            End If
        Catch ex As Exception
            Return ""
        End Try
    End Function
    Function getprice(str)
        str = str.ToString.ToLower
        Try
            If InStr(str, "<span class=""a-offscreen"">") Then
                Dim asina = Split(str, "<span class=""a-offscreen"">")(1)
                Dim asinb = Split(asina, "</span><span aria-hidden=")(0)
                If IsNotWhiteSpace(asinb) Then
                    Return asinb
                Else
                    Return "0"
                End If
            Else
                Return "0"
            End If
        Catch ex As Exception
            Return "0"
        End Try
    End Function
    Function getshipfee(str)
        Try
            If InStr(str, "data-csa-c-delivery-price=""") Then
                Dim asina = Split(str, "data-csa-c-delivery-price=""")(1)
                Dim asinb = Split(asina, """ data-csa-c-value-proposition=")(0)
                Dim asinc = GetNumbers(asinb)
                If IsNotWhiteSpace(asinc) Then
                    Return asinc
                Else
                    Return "0"
                End If
            Else
                Return "0"
            End If
        Catch ex As Exception
            Return "0"
        End Try
    End Function
    Function getcurrency(str)
        Try
            Dim currency = "未知"
            If InStr(str, "$") Then
                Return "美元"
            End If
            If InStr(str, "₹") Then
                Return "印度卢比"
            End If
            If InStr(str, "£") Then
                Return "英镑"
            End If
            If InStr(str, "€") Then
                Return "欧元"
            End If
            If InStr(str, "zł") Then
                Return "兹罗提"
            End If
            If InStr(str, "kr") Then
                Return "瑞典克朗"
            End If
            Return currency
        Catch ex As Exception
            Return "未知"
        End Try
    End Function
    Function getfba(str)
        Try
            'If InStr(str, "a-size-small"">Amazon") > 0 Or InStr(str, "Fulfilled by Amazon") > 0 Or InStr(str, "Expédié par Amazon") > 0 Or InStr(str, "Versand durch Amazon") > 0 Or InStr(str, "Realizacja przez Amazon") > 0 Then
            '    Return "否"
            'Else
            '    Return "是"
            'End If
            If InStr(str, "sellerProfileTriggerId") > 0 Then
                Return "是"
            Else
                Return "否"
            End If
        Catch ex As Exception
            Return "未知"
        End Try
    End Function
    Function gettotalmarkurl(str)
        Dim totalmarkurl = ""
        Try
            If InStr(str, "marketplaceID=") Then
                Dim asina = Split(str, "marketplaceID=")(1)
                Dim asinb = Split(asina, "&")(0)
                Dim asinc = Split(asina, "seller=")(1)
                Dim asind = Split(asinc, "&")(0)
                Return "/sp?marketplaceID=" & asinb & "&seller=" & asind & "&ref=dp_merchant_link"
            End If
            If InStr(str, "' id='sellerProfileTriggerId") Then
                Dim asina = Split(str, "' id='sellerProfileTriggerId")(0)
                Dim asinb = Split(asina, "class=""a-size-small""><a href='")(1)
                Return asinb
            End If
            If InStr(str, """ id=""sellerProfileTriggerId"">") Then
                Dim asina = Split(str, """ id=""sellerProfileTriggerId"">")(0)
                Dim asinb = Split(asina, "class=""a-size-small""><a href=""")(1)
                Dim asinm = Replace(asinb, "amp;", "")
                Return asinm
            End If
            Return totalmarkurl
        Catch ex As Exception
            Return ""
        End Try
    End Function
    Function gettotalmark(str)
        Try
            If InStr(str, "a-link-normal feedback-detail-description"" href=""#""><b>") Then
                Dim asina = Split(str, "a-link-normal feedback-detail-description"" href=""#""><b>")(1)
                Dim asinb = Split(asina, "</b>")(0)
                Return asinb
            Else
                Return "0"
            End If
        Catch ex As Exception
            Return "0"
        End Try
    End Function
    Function getbsr(str) As String
        Try
            If InStr(str, "a-unordered-list a-nostyle a-vertical zg_hrsr"">  <li><span class=""a-list-item"">") Then
                Dim asina = Split(str, "a-unordered-list a-nostyle a-vertical zg_hrsr"">  <li><span class=""a-list-item"">")(1)
                Dim asinb = Split(asina, "<a href=")(0)
                asinb = GetreviewNumbers(asinb)
                Return asinb
            Else
                Return "0"
            End If
        Catch ex As Exception
            Return "0"
        End Try
    End Function
    Function GetNumbers(ByVal strp As String) As String
        Dim strReturn As String = String.Empty
        If strp Is Nothing OrElse strp.Trim() = "" Then
            strReturn = ""
        End If
        strp = Replace(strp, ",", ".")
        For Each chrTemp As Char In strp
            If [Char].IsNumber(chrTemp) Or chrTemp = "." Then
                strReturn += chrTemp.ToString()
            End If
        Next
        Return strReturn
    End Function
    Function GetreviewNumbers(ByVal strp As String) As String
        Dim strReturn As String = String.Empty
        If strp Is Nothing OrElse strp.Trim() = "" Then
            strReturn = ""
        End If
        'strp = Replace(strp, ",", ".")
        For Each chrTemp As Char In strp
            If [Char].IsNumber(chrTemp) Then
                strReturn += chrTemp.ToString()
            End If
        Next
        Return strReturn
    End Function
    Function getnodenodename(str) As String
        Try
            If InStr(str, "a-link-normal a-color-tertiary") Then

                Dim asina = Split(str, "a-link-normal a-color-tertiary")
                Dim asinb = Split(asina(UBound(asina)), "</a>")(0)
                Dim asinc = Split(asinb, """>")(1)
                asinc = Trimd(asinc)
                Return asinc
            Else
                Return ""
            End If
        Catch ex As Exception
            Return ""
        End Try
    End Function
    Function getc_time(str) As String
        Dim ctime = "未知"
        Try
            'uk,com,ca,auprodDetAttrValue
            If InStr(str, "Date First Available") > 0 Then
                Dim ctimea = Split(str, "Date First Available")(1)
                If InStr(ctimea, "prodDetAttrValue"">") > 0 Then
                    Dim ctimeb = Split(ctimea, "prodDetAttrValue"">")(1)
                    ctime = Split(ctimeb, "</td>")(0)
                Else
                    Dim ctimeb = Split(ctimea, "</span> <span>")(1)
                    ctime = Split(ctimeb, "</span> </span>")(0)
                End If
            End If
            'es
            If InStr(str, "Producto en Amazon.es desde") > 0 Then
                Dim ctimea = Split(str, "Producto en Amazon.es desde")(1)
                If InStr(ctimea, "prodDetAttrValue"">") > 0 Then
                    Dim ctimeb = Split(ctimea, "prodDetAttrValue"">")(1)
                    ctime = Split(ctimeb, "</td>")(0)
                Else
                    Dim ctimeb = Split(ctimea, "</span> <span>")(1)
                    ctime = Split(ctimeb, "</span> </span>")(0)
                End If
            End If
            'fr
            If InStr(str, "Date de mise en ligne sur Amazon.fr") > 0 Then
                Dim ctimea = Split(str, "Date de mise en ligne sur Amazon.fr")(1)
                If InStr(ctimea, "prodDetAttrValue"">") > 0 Then
                    Dim ctimeb = Split(ctimea, "prodDetAttrValue"">")(1)
                    ctime = Split(ctimeb, "</td>")(0)
                Else
                    Dim ctimeb = Split(ctimea, "</span> <span>")(1)
                    ctime = Split(ctimeb, "</span> </span>")(0)
                End If
            End If
            'it
            If InStr(str, "Disponibile su Amazon.it a partire dal") > 0 Then
                Dim ctimea = Split(str, "Disponibile su Amazon.it a partire dal")(1)
                If InStr(ctimea, "prodDetAttrValue"">") > 0 Then
                    Dim ctimeb = Split(ctimea, "prodDetAttrValue"">")(1)
                    ctime = Split(ctimeb, "</td>")(0)
                Else
                    Dim ctimeb = Split(ctimea, "</span> <span>")(1)
                    ctime = Split(ctimeb, "</span> </span>")(0)
                End If
            End If
            'mx
            If InStr(str, "Producto en Amazon.com.mx desde") > 0 Then
                Dim ctimea = Split(str, "Producto en Amazon.com.mx desde")(1)
                If InStr(ctimea, "prodDetAttrValue"">") > 0 Then
                    Dim ctimeb = Split(ctimea, "prodDetAttrValue"">")(1)
                    ctime = Split(ctimeb, "</td>")(0)
                Else
                    Dim ctimeb = Split(ctimea, "</span> <span>")(1)
                    ctime = Split(ctimeb, "</span> </span>")(0)
                End If
            End If
            'se
            If InStr(str, "Första tillgängliga datum") > 0 Then
                Dim ctimea = Split(str, "Första tillgängliga datum")(1)
                If InStr(ctimea, "prodDetAttrValue"">") > 0 Then
                    Dim ctimeb = Split(ctimea, "prodDetAttrValue"">")(1)
                    ctime = Split(ctimeb, "</td>")(0)
                Else
                    Dim ctimeb = Split(ctimea, "</span> <span>")(1)
                    ctime = Split(ctimeb, "</span> </span>")(0)
                End If
            End If
            'de
            If InStr(str, "Im Angebot von Amazon.de seit") > 0 Then
                Dim ctimea = Split(str, "Im Angebot von Amazon.de seit")(1)
                If InStr(ctimea, "prodDetAttrValue"">") > 0 Then
                    Dim ctimeb = Split(ctimea, "prodDetAttrValue"">")(1)
                    ctime = Split(ctimeb, "</td>")(0)
                Else
                    Dim ctimeb = Split(ctimea, "</span> <span>")(1)
                    ctime = Split(ctimeb, "</span> </span>")(0)
                End If
            End If
            'in
            If InStr(str, "प्रथम उपलब्धता की तारीख़") > 0 Then
                Dim ctimea = Split(str, "प्रथम उपलब्धता की तारीख़")(1)
                If InStr(ctimea, "prodDetAttrValue"">") > 0 Then
                    Dim ctimeb = Split(ctimea, "prodDetAttrValue"">")(1)
                    ctime = Split(ctimeb, "</td>")(0)
                Else
                    Dim ctimeb = Split(ctimea, "</span> <span>")(1)
                    ctime = Split(ctimeb, "</span> </span>")(0)
                End If
            End If
            'pl
            If InStr(str, "Data pierwszej dostępności") > 0 Then
                Dim ctimea = Split(str, "Data pierwszej dostępności")(1)
                If InStr(ctimea, "prodDetAttrValue"">") > 0 Then
                    Dim ctimeb = Split(ctimea, "prodDetAttrValue"">")(1)
                    ctime = Split(ctimeb, "</td>")(0)
                Else
                    Dim ctimeb = Split(ctimea, "</span> <span>")(1)
                    ctime = Split(ctimeb, "</span> </span>")(0)
                End If
            End If

            Return Trimd(ctime)
        Catch ex As Exception
            Return "未知"
        End Try
    End Function
    Function Trimd(str) As String
        str = Replace(str, vbTab, "")
        str = Replace(str, vbCrLf, "")
        str = Replace(str, vbLf, "")
        str = Replace(str, vbCr, "")
        str = Trim(Replace(str, vbNewLine, ""))
        Return str
    End Function
    Function getnodebrowser(str) As String
        Try
            If InStr(str, "a-unordered-list a-nostyle a-vertical zg_hrsr"">  <li><span class=""a-list-item"">") Then
                Dim asina = Split(str, "a-unordered-list a-nostyle a-vertical zg_hrsr"">  <li><span class=""a-list-item"">")(1)
                Dim asinb = Split(asina, "/gp/bestsellers/")(1)
                Dim asinc = Split(asinb, "/")(1)
                Return GetNumbers(asinc)
            ElseIf InStr(str, "a-link-normal a-color-tertiary") Then
                Dim asina = Split(str, "a-link-normal a-color-tertiary")
                Dim asinb = asina(UBound(asina))
                Dim asinc = Split(asinb, """>")(0)
                Dim asind = Split(asinc, "node=")(1)
                Return GetNumbers(asind)
            Else
                Return ""
            End If
        Catch ex As Exception
            Return ""
        End Try
    End Function
    Function EnumNetworkAdapters() As String
        Try
            Dim query As System.Management.ManagementObjectSearcher = New System.Management.ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapterConfiguration")
            Dim queryCollection As System.Management.ManagementObjectCollection = query.Get()
            Dim mo As New System.Management.ManagementObject
            For Each mo In queryCollection
                If IsDBNull(mo.Item("macaddress")) = False Then
                    If mo.Item("macaddress") <> "" Then
                        EnumNetworkAdapters = Replace(mo.Item("macaddress"), ":", "-")
                    End If
                End If
                'If IsDBNull(mo.Item("IPAddress")) = False Then
                '    Dim temp As String
                '    temp = Join(mo.Item("IPAddress"), ".")
                '    If temp <> "" Then
                '        EnumNetworkAdapters &= temp & "|||"
                '    End If
                'End If
            Next
        Catch ex As Exception
            EnumNetworkAdapters = ex.ToString
        End Try 
End Function
End Module
